From f1f23b09ae20fa4d6288a9139462e49ff77d98c4 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 25 Feb 2015 19:00:52 +0100 Subject: Added GetSnowStartHeight returns the height of a biome where it starts snowing --- src/BiomeDef.cpp | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/BiomeDef.h | 3 ++ 2 files changed, 130 insertions(+) diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 188e06173..43f3ef0b1 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -222,3 +222,130 @@ bool IsBiomeCold(EMCSBiome a_Biome) + +int GetSnowStartHeight(EMCSBiome a_Biome) +{ + switch (a_Biome) + { + case biIcePlainsSpikes: + case biIcePlains: + case biIceMountains: + case biFrozenRiver: + case biColdBeach: + case biColdTaiga: + case biColdTaigaHills: + case biColdTaigaM: + { + // Always snow + return -1; + } + + case biExtremeHills: + case biExtremeHillsM: + case biExtremeHillsPlus: + case biExtremeHillsPlusM: + case biStoneBeach: + { + // Starts snowing at 96 + return 96; + } + + case biTaiga: + case biTaigaHills: + case biTaigaM: + { + // Start snowing at 130 + return 130; + } + + case biMegaTaiga: + case biMegaSpruceTaiga: + case biMegaTaigaHills: + case biMegaSpruceTaigaHills: + { + // Start snowing at 160 + return 160; + } + + case biRiver: + case biOcean: + case biDeepOcean: + { + // Starts snowing at 280 + return 280; + } + + case biBirchForest: + case biBirchForestHills: + case biBirchForestM: + case biBirchForestHillsM: + { + // Starts snowing at 335 + return 335; + } + + case biForest: + case biForestHills: + case biFlowerForest: + case biRoofedForest: + case biRoofedForestM: + { + // Starts snowing at 400 + return 400; + } + + case biPlains: + case biSunflowerPlains: + case biSwampland: + case biSwamplandM: + case biBeach: + { + // Starts snowing at 460 + return 460; + } + + case biMushroomIsland: + case biMushroomShore: + { + // Starts snowing at 520 + return 520; + } + + case biJungle: + case biJungleHills: + case biJungleM: + case biJungleEdge: + case biJungleEdgeM: + { + // Starts snowing at 550 + return 550; + } + + case biDesert: + case biDesertHills: + case biDesertM: + case biSavanna: + case biSavannaM: + case biSavannaPlateau: + case biSavannaPlateauM: + case biMesa: + case biMesaBryce: + case biMesaPlateau: + case biMesaPlateauF: + case biMesaPlateauFM: + case biMesaPlateauM: + { + // These biomes don't actualy have any downfall. + return 1000; + } + + default: + { + return -1; + } + } +} + + + + diff --git a/src/BiomeDef.h b/src/BiomeDef.h index 84751cfd7..cda12556a 100644 --- a/src/BiomeDef.h +++ b/src/BiomeDef.h @@ -129,4 +129,7 @@ extern bool IsBiomeVeryCold(EMCSBiome a_Biome); Doesn't report Very Cold biomes, use IsBiomeVeryCold() for those. */ extern bool IsBiomeCold(EMCSBiome a_Biome); +/** Returns the height when a biome when a biome starts snowing.*/ +extern int GetSnowStartHeight(EMCSBiome a_Biome); + // tolua_end -- cgit v1.2.3 From b3f07511306080545fb3e763e99ce31796d7de7d Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 25 Feb 2015 19:02:08 +0100 Subject: Weather: Snow starts forming when the top block is at the right height or higher --- src/Chunk.cpp | 123 +++++++++++++++++++++++++++------------------------------- 1 file changed, 57 insertions(+), 66 deletions(-) diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 08cb237c3..e05fa4a99 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -874,80 +874,71 @@ void cChunk::ApplyWeatherToTop() int X = m_World->GetTickRandomNumber(15); int Z = m_World->GetTickRandomNumber(15); - switch (GetBiomeAt(X, Z)) - { - case biTaiga: - case biFrozenOcean: - case biFrozenRiver: - case biIcePlains: - case biIceMountains: - case biTaigaHills: - { - // TODO: Check light levels, don't snow over when the BlockLight is higher than (7?) - int Height = GetHeight(X, Z); - BLOCKTYPE TopBlock = GetBlock(X, Height, Z); - NIBBLETYPE TopMeta = GetMeta (X, Height, Z); - if (m_World->IsDeepSnowEnabled() && (TopBlock == E_BLOCK_SNOW)) + + // TODO: Check light levels, don't snow over when the BlockLight is higher than (7?) + int Height = GetHeight(X, Z); + + if (GetSnowStartHeight(GetBiomeAt(X, Z)) > Height) + { + return; + } + + BLOCKTYPE TopBlock = GetBlock(X, Height, Z); + NIBBLETYPE TopMeta = GetMeta (X, Height, Z); + if (m_World->IsDeepSnowEnabled() && (TopBlock == E_BLOCK_SNOW)) + { + int MaxSize = 7; + BLOCKTYPE BlockType[4]; + NIBBLETYPE BlockMeta[4]; + UnboundedRelGetBlock(X - 1, Height, Z, BlockType[0], BlockMeta[0]); + UnboundedRelGetBlock(X + 1, Height, Z, BlockType[1], BlockMeta[1]); + UnboundedRelGetBlock(X, Height, Z - 1, BlockType[2], BlockMeta[2]); + UnboundedRelGetBlock(X, Height, Z + 1, BlockType[3], BlockMeta[3]); + for (int i = 0; i < 4; i++) + { + switch (BlockType[i]) { - int MaxSize = 7; - BLOCKTYPE BlockType[4]; - NIBBLETYPE BlockMeta[4]; - UnboundedRelGetBlock(X - 1, Height, Z, BlockType[0], BlockMeta[0]); - UnboundedRelGetBlock(X + 1, Height, Z, BlockType[1], BlockMeta[1]); - UnboundedRelGetBlock(X, Height, Z - 1, BlockType[2], BlockMeta[2]); - UnboundedRelGetBlock(X, Height, Z + 1, BlockType[3], BlockMeta[3]); - for (int i = 0; i < 4; i++) + case E_BLOCK_AIR: { - switch (BlockType[i]) - { - case E_BLOCK_AIR: - { - MaxSize = 0; - break; - } - case E_BLOCK_SNOW: - { - MaxSize = std::min(BlockMeta[i] + 1, MaxSize); - break; - } - } - } - if (TopMeta < MaxSize) - { - FastSetBlock(X, Height, Z, E_BLOCK_SNOW, TopMeta + 1); + MaxSize = 0; + break; } - else if (TopMeta > MaxSize) + case E_BLOCK_SNOW: { - FastSetBlock(X, Height, Z, E_BLOCK_SNOW, TopMeta - 1); + MaxSize = std::min(BlockMeta[i] + 1, MaxSize); + break; } } - else if (cBlockInfo::IsSnowable(TopBlock) && (Height + 1 < cChunkDef::Height)) - { - SetBlock(X, Height + 1, Z, E_BLOCK_SNOW, 0); - } - else if (IsBlockWater(TopBlock) && (TopMeta == 0)) - { - SetBlock(X, Height, Z, E_BLOCK_ICE, 0); - } - else if ( - (m_World->IsDeepSnowEnabled()) && - ( - (TopBlock == E_BLOCK_RED_ROSE) || - (TopBlock == E_BLOCK_YELLOW_FLOWER) || - (TopBlock == E_BLOCK_RED_MUSHROOM) || - (TopBlock == E_BLOCK_BROWN_MUSHROOM) - ) - ) - { - SetBlock(X, Height, Z, E_BLOCK_SNOW, 0); - } - break; - } // case (snowy biomes) - default: + } + if (TopMeta < MaxSize) { - break; + FastSetBlock(X, Height, Z, E_BLOCK_SNOW, TopMeta + 1); + } + else if (TopMeta > MaxSize) + { + FastSetBlock(X, Height, Z, E_BLOCK_SNOW, TopMeta - 1); } - } // switch (biome) + } + else if (cBlockInfo::IsSnowable(TopBlock) && (Height + 1 < cChunkDef::Height)) + { + SetBlock(X, Height + 1, Z, E_BLOCK_SNOW, 0); + } + else if (IsBlockWater(TopBlock) && (TopMeta == 0)) + { + SetBlock(X, Height, Z, E_BLOCK_ICE, 0); + } + else if ( + (m_World->IsDeepSnowEnabled()) && + ( + (TopBlock == E_BLOCK_RED_ROSE) || + (TopBlock == E_BLOCK_YELLOW_FLOWER) || + (TopBlock == E_BLOCK_RED_MUSHROOM) || + (TopBlock == E_BLOCK_BROWN_MUSHROOM) + ) + ) + { + SetBlock(X, Height, Z, E_BLOCK_SNOW, 0); + } } -- cgit v1.2.3 From ba3eaf922377c4b19d66b205a47c0698ea02f5b4 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 25 Feb 2015 19:12:53 +0100 Subject: Snow finisher uses GetSnowStartHeight instead of specific biomes --- src/Generating/FinishGen.cpp | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index e10cb00f8..548c50563 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -470,30 +470,22 @@ void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc) { for (int x = 0; x < cChunkDef::Width; x++) { - switch (a_ChunkDesc.GetBiome(x, z)) + int Height = a_ChunkDesc.GetHeight(x, z); + if (GetSnowStartHeight(a_ChunkDesc.GetBiome(x, z)) > Height) { - case biIcePlains: - case biIceMountains: - case biTaiga: - case biTaigaHills: - case biFrozenRiver: - case biFrozenOcean: - { - int Height = a_ChunkDesc.GetHeight(x, z); - if (cBlockInfo::IsSnowable(a_ChunkDesc.GetBlockType(x, Height, z)) && (Height < cChunkDef::Height - 1)) - { - a_ChunkDesc.SetBlockType(x, Height + 1, z, E_BLOCK_SNOW); - a_ChunkDesc.SetHeight(x, z, Height + 1); - } - break; - } - default: - { - // There's no snow in the other biomes. - break; - } + // Height isn't high enough for snow to start forming. + continue; } - } + + if (!cBlockInfo::IsSnowable(a_ChunkDesc.GetBlockType(x, Height, z)) && (Height < cChunkDef::Height - 1)) + { + // The top block can't be snown over. + continue; + } + + a_ChunkDesc.SetBlockType(x, Height + 1, z, E_BLOCK_SNOW); + a_ChunkDesc.SetHeight(x, z, Height + 1); + } // for x } // for z } -- cgit v1.2.3 From ac2c88b4510c8504cf015bfa69fc844aa9293e34 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 25 Feb 2015 19:22:44 +0100 Subject: Ice finisher uses GetSnowStartHeight instead of specific biomes --- src/Generating/FinishGen.cpp | 45 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 548c50563..d8fb9c8c0 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -503,34 +503,27 @@ void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc) { for (int x = 0; x < cChunkDef::Width; x++) { - switch (a_ChunkDesc.GetBiome(x, z)) + int Height = a_ChunkDesc.GetHeight(x, z); + if (GetSnowStartHeight(a_ChunkDesc.GetBiome(x, z)) > Height) { - case biIcePlains: - case biIceMountains: - case biTaiga: - case biTaigaHills: - case biFrozenRiver: - case biFrozenOcean: - { - int Height = a_ChunkDesc.GetHeight(x, z); - switch (a_ChunkDesc.GetBlockType(x, Height, z)) - { - case E_BLOCK_WATER: - case E_BLOCK_STATIONARY_WATER: - { - a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_ICE); - break; - } - } - break; - } - default: - { - // No icy water in other biomes. - break; - } + // Height isn't high enough for snow to start forming. + continue; } - } + + if (!IsBlockWater(a_ChunkDesc.GetBlockType(x, Height, z))) + { + // The block isn't a water block. + continue; + } + + if (a_ChunkDesc.GetBlockMeta(x, Height, z) != 0) + { + // The water block isn't a source block. + continue; + } + + a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_ICE); + } // for x } // for z } -- cgit v1.2.3 From 81e8577cfd9d1a8dd40ca1e9fc25c83f990b7f82 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 26 Feb 2015 20:26:45 +0100 Subject: changed int to unsigned And return 0 instead of -1 --- src/BiomeDef.cpp | 6 +++--- src/BiomeDef.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 43f3ef0b1..bdc582863 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -223,7 +223,7 @@ bool IsBiomeCold(EMCSBiome a_Biome) -int GetSnowStartHeight(EMCSBiome a_Biome) +unsigned GetSnowStartHeight(EMCSBiome a_Biome) { switch (a_Biome) { @@ -237,7 +237,7 @@ int GetSnowStartHeight(EMCSBiome a_Biome) case biColdTaigaM: { // Always snow - return -1; + return 0; } case biExtremeHills: @@ -341,7 +341,7 @@ int GetSnowStartHeight(EMCSBiome a_Biome) default: { - return -1; + return 0; } } } diff --git a/src/BiomeDef.h b/src/BiomeDef.h index cda12556a..9b2369e5f 100644 --- a/src/BiomeDef.h +++ b/src/BiomeDef.h @@ -130,6 +130,6 @@ Doesn't report Very Cold biomes, use IsBiomeVeryCold() for those. */ extern bool IsBiomeCold(EMCSBiome a_Biome); /** Returns the height when a biome when a biome starts snowing.*/ -extern int GetSnowStartHeight(EMCSBiome a_Biome); +extern unsigned GetSnowStartHeight(EMCSBiome a_Biome); // tolua_end -- cgit v1.2.3 From 224df08d30b556c0d7214e451fd4322ca75f32ea Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 28 Feb 2015 17:27:28 +0100 Subject: GetSnowStartHeight returns an int --- src/BiomeDef.cpp | 2 +- src/BiomeDef.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index bdc582863..3e34ebdbe 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -223,7 +223,7 @@ bool IsBiomeCold(EMCSBiome a_Biome) -unsigned GetSnowStartHeight(EMCSBiome a_Biome) +int GetSnowStartHeight(EMCSBiome a_Biome) { switch (a_Biome) { diff --git a/src/BiomeDef.h b/src/BiomeDef.h index 9b2369e5f..cda12556a 100644 --- a/src/BiomeDef.h +++ b/src/BiomeDef.h @@ -130,6 +130,6 @@ Doesn't report Very Cold biomes, use IsBiomeVeryCold() for those. */ extern bool IsBiomeCold(EMCSBiome a_Biome); /** Returns the height when a biome when a biome starts snowing.*/ -extern unsigned GetSnowStartHeight(EMCSBiome a_Biome); +extern int GetSnowStartHeight(EMCSBiome a_Biome); // tolua_end -- cgit v1.2.3